﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using KPIS.GERP.GAMS.DAL;
using KPIS.GERP.GAMS.MODEL;
using Telerik.Web.UI;
using System.Collections.Generic;

namespace KPIS.GERP.GAMS.APP.App_UI.Forms
{
    public partial class ACM_CHANGE_Value : System.Web.UI.Page
    {
        D_ACM_MAS_BaseAccount baseAcc = new D_ACM_MAS_BaseAccount();
        D_ACM_MAS_Account acc = new D_ACM_MAS_Account();
        Commons.Main main = new Commons.Main();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadAllDDL();
                LoadData();
            }
        }

        protected void LoadAllDDL()
        {
            IList<M_ACM_MAS_Account> infoList = acc.GetListAccount();

            ddlCashAccountSeq.DataSource = infoList;
            ddlCashAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlCashAccountSeq);
            ddlCollateralAccountSeq1.DataSource = infoList;
            ddlCollateralAccountSeq1.DataBind();
            main.InsertEmptyDDLSelect(ddlCollateralAccountSeq1);
            ddlCollateralAccountSeq2.DataSource = infoList;
            ddlCollateralAccountSeq2.DataBind();
            main.InsertEmptyDDLSelect(ddlCollateralAccountSeq2);
            ddlCollateralAccountSeq3.DataSource = infoList;
            ddlCollateralAccountSeq3.DataBind();
            main.InsertEmptyDDLSelect(ddlCollateralAccountSeq3);
            ddlCollateralAccountSeq4.DataSource = infoList;
            ddlCollateralAccountSeq4.DataBind();
            main.InsertEmptyDDLSelect(ddlCollateralAccountSeq4);
            ddlDirectPayAccountSeq.DataSource = infoList;
            ddlDirectPayAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlDirectPayAccountSeq);
            ddlDnCrAccountSeq.DataSource = infoList;
            ddlDnCrAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlDnCrAccountSeq);
            ddlGovDepositAccountSeq.DataSource = infoList;
            ddlGovDepositAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlGovDepositAccountSeq);
            ddlGovIncomeAccountSeq.DataSource = infoList;
            ddlGovIncomeAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlGovIncomeAccountSeq);
            ddlIncomeBBAccountSeq.DataSource = infoList;
            ddlIncomeBBAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlIncomeBBAccountSeq);
            ddlLoanAccountSeq.DataSource = infoList;
            ddlLoanAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlLoanAccountSeq);
            ddlOverAccountSeq.DataSource = infoList;
            ddlOverAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlOverAccountSeq);
            ddlPayIncomeAccountSeq.DataSource = infoList;
            ddlPayIncomeAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlPayIncomeAccountSeq);
            ddlPenaltyAccountSeq.DataSource = infoList;
            ddlPenaltyAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlPenaltyAccountSeq);
            ddlRedemptionAccountSeq.DataSource = infoList;
            ddlRedemptionAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlRedemptionAccountSeq);
            ddlRemainAccountSeq.DataSource = infoList;
            ddlRemainAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlRemainAccountSeq);
            ddlWaitIncomeBBAccountSeq.DataSource = infoList;
            ddlWaitIncomeBBAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlWaitIncomeBBAccountSeq);
            ddlWaitAccountSeq.DataSource = infoList;
            ddlWaitAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlWaitAccountSeq);

            ddlPayrollTaxAccountSeq.DataSource = infoList;
            ddlPayrollTaxAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlPayrollTaxAccountSeq);
            ddlPersonalTaxAccountSeq.DataSource = infoList;
            ddlPersonalTaxAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlPersonalTaxAccountSeq);
            ddlCompanyTaxAccountSeq.DataSource = infoList;
            ddlCompanyTaxAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlCompanyTaxAccountSeq);
            ddlRevenueVatCreditorAccountSeq.DataSource = infoList;
            ddlRevenueVatCreditorAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlRevenueVatCreditorAccountSeq);
            ddlRevenueVatDebtorAccountSeq.DataSource = infoList;
            ddlRevenueVatDebtorAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlRevenueVatDebtorAccountSeq);
            ddlBuyVatAccountSeq.DataSource = infoList;
            ddlBuyVatAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlBuyVatAccountSeq);
            ddlSaleVatAccountSeq.DataSource = infoList;
            ddlSaleVatAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlSaleVatAccountSeq);
            ddlBuyVSaleVatAccountSeq.DataSource = infoList;
            ddlBuyVSaleVatAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlBuyVSaleVatAccountSeq);
            ddlSuspenseInputTaxAccountSeq.DataSource = infoList;
            ddlSuspenseInputTaxAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlSuspenseInputTaxAccountSeq);
            ddlCloseIncomeAccountSeq.DataSource = infoList;
            ddlCloseIncomeAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlCloseIncomeAccountSeq);
            ddlCloseOutcomeAccountSeq.DataSource = infoList;
            ddlCloseOutcomeAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlCloseOutcomeAccountSeq);
            ddlCloseCapitalAccountSeq.DataSource = infoList;
            ddlCloseCapitalAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlCloseCapitalAccountSeq);
            ddlCloseIncomeOutcomeAccountSeq.DataSource = infoList;
            ddlCloseIncomeOutcomeAccountSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlCloseIncomeOutcomeAccountSeq);
            ddlCrossBudgetExpenseSeq.DataSource = infoList;
            ddlCrossBudgetExpenseSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlCrossBudgetExpenseSeq);
            ddlCrossBudgetIncomeSeq.DataSource = infoList;
            ddlCrossBudgetIncomeSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlCrossBudgetIncomeSeq);
            ddlDisposeSeq.DataSource = infoList;
            ddlDisposeSeq.DataBind();
            main.InsertEmptyDDLSelect(ddlDisposeSeq);
        }

        protected void LoadData()
        {
            M_ACM_MAS_BaseAccount info = baseAcc.GetList();
            ddlCashAccountSeq.SelectedValue = info.cash_account_seq.ToString();
            ddlCollateralAccountSeq1.SelectedValue = info.collateral_account_seq1.ToString();
            ddlCollateralAccountSeq2.SelectedValue = info.collateral_account_seq2.ToString();
            ddlCollateralAccountSeq3.SelectedValue = info.collateral_account_seq3.ToString();
            ddlCollateralAccountSeq4.SelectedValue = info.collateral_account_seq4.ToString();
            ddlDirectPayAccountSeq.SelectedValue = info.direct_pay_account_seq.ToString();
            ddlDnCrAccountSeq.SelectedValue = info.dn_cr_account_seq.ToString();
            ddlGovDepositAccountSeq.SelectedValue = info.gov_deposit_account_seq.ToString();
            ddlGovIncomeAccountSeq.SelectedValue = info.gov_income_account_seq.ToString();
            ddlIncomeBBAccountSeq.SelectedValue = info.income_bb_account_seq.ToString();
            ddlLoanAccountSeq.SelectedValue = info.loan_account_seq.ToString();
            ddlOverAccountSeq.SelectedValue = info.over_account_seq.ToString();
            ddlPayIncomeAccountSeq.SelectedValue = info.pay_income_account_seq.ToString();
            ddlPenaltyAccountSeq.SelectedValue = info.penalty_account_seq.ToString();
            ddlRedemptionAccountSeq.SelectedValue = info.redemption_account_seq.ToString();
            ddlRemainAccountSeq.SelectedValue = info.remain_account_seq.ToString();
            ddlWaitAccountSeq.SelectedValue = info.wait_account_seq.ToString();
            ddlWaitIncomeBBAccountSeq.SelectedValue = info.wait_income_bb_account_seq.ToString();
            ddlPayrollTaxAccountSeq.SelectedValue = info.payroll_tax_account_seq.ToString();
            ddlPersonalTaxAccountSeq.SelectedValue = info.personal_tax_account_seq.ToString();
            ddlCompanyTaxAccountSeq.SelectedValue = info.company_tax_account_seq.ToString();
            ddlRevenueVatCreditorAccountSeq.SelectedValue = info.revenue_vat_debtor_account_seq.ToString();
            ddlRevenueVatDebtorAccountSeq.SelectedValue = info.revenue_vat_creditor_account_seq.ToString();
            ddlBuyVatAccountSeq.SelectedValue = info.buy_vat_account_seq.ToString();
            ddlSaleVatAccountSeq.SelectedValue = info.sale_vat_account_seq.ToString();
            ddlBuyVSaleVatAccountSeq.SelectedValue = info.buy_v_sale_vat_account_seq.ToString();
            ddlSuspenseInputTaxAccountSeq.SelectedValue = info.suspense_input_tax_account_seq.ToString();
            ddlCloseIncomeAccountSeq.SelectedValue = info.close_income_account_seq.ToString();
            ddlCloseOutcomeAccountSeq.SelectedValue = info.close_outcome_account_seq.ToString();
            ddlCloseCapitalAccountSeq.SelectedValue = info.close_capital_account_seq.ToString();
            ddlCloseIncomeOutcomeAccountSeq.SelectedValue = info.close_income_outcome_account_seq.ToString();
            ddlCrossBudgetExpenseSeq.SelectedValue = info.cross_budget_expense_account_seq.ToString();
            ddlCrossBudgetIncomeSeq.SelectedValue = info.cross_budget_income_account_seq.ToString();
            ddlDisposeSeq.SelectedValue = info.dispose_account_seq.ToString();
        }

        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            M_ACM_MAS_BaseAccount info = new M_ACM_MAS_BaseAccount();

            info.cash_account_seq = main.ConvertNullInt(ddlCashAccountSeq.SelectedValue);
            info.collateral_account_seq1 = main.ConvertNullInt(ddlCollateralAccountSeq1.SelectedValue);
            info.collateral_account_seq2 = main.ConvertNullInt(ddlCollateralAccountSeq2.SelectedValue);
            info.collateral_account_seq3 = main.ConvertNullInt(ddlCollateralAccountSeq3.SelectedValue);
            info.collateral_account_seq4 = main.ConvertNullInt(ddlCollateralAccountSeq4.SelectedValue);
            info.direct_pay_account_seq = main.ConvertNullInt(ddlDirectPayAccountSeq.SelectedValue);
            info.dn_cr_account_seq = main.ConvertNullInt(ddlDnCrAccountSeq.SelectedValue);
            info.gov_deposit_account_seq = main.ConvertNullInt(ddlGovDepositAccountSeq.SelectedValue);
            info.gov_income_account_seq = main.ConvertNullInt(ddlGovIncomeAccountSeq.SelectedValue);
            info.income_bb_account_seq = main.ConvertNullInt(ddlIncomeBBAccountSeq.SelectedValue);
            info.loan_account_seq = main.ConvertNullInt(ddlLoanAccountSeq.SelectedValue);
            info.over_account_seq = main.ConvertNullInt(ddlOverAccountSeq.SelectedValue);
            info.pay_income_account_seq = main.ConvertNullInt(ddlPayIncomeAccountSeq.SelectedValue);
            info.penalty_account_seq = main.ConvertNullInt(ddlPenaltyAccountSeq.SelectedValue);
            info.redemption_account_seq = main.ConvertNullInt(ddlRedemptionAccountSeq.SelectedValue);
            info.remain_account_seq = main.ConvertNullInt(ddlRemainAccountSeq.SelectedValue);
            info.wait_account_seq = main.ConvertNullInt(ddlWaitAccountSeq.SelectedValue);
            info.wait_income_bb_account_seq = main.ConvertNullInt(ddlWaitIncomeBBAccountSeq.SelectedValue);
            info.payroll_tax_account_seq = main.ConvertNullInt(ddlPayrollTaxAccountSeq.SelectedValue);
            info.personal_tax_account_seq = main.ConvertNullInt(ddlPersonalTaxAccountSeq.SelectedValue);
            info.company_tax_account_seq = main.ConvertNullInt(ddlCompanyTaxAccountSeq.SelectedValue);
            info.revenue_vat_debtor_account_seq = main.ConvertNullInt(ddlRevenueVatDebtorAccountSeq.SelectedValue);
            info.revenue_vat_creditor_account_seq = main.ConvertNullInt(ddlRevenueVatCreditorAccountSeq.SelectedValue);
            info.buy_vat_account_seq = main.ConvertNullInt(ddlBuyVatAccountSeq.SelectedValue);
            info.sale_vat_account_seq = main.ConvertNullInt(ddlSaleVatAccountSeq.SelectedValue);
            info.buy_v_sale_vat_account_seq = main.ConvertNullInt(ddlBuyVSaleVatAccountSeq.SelectedValue);
            info.suspense_input_tax_account_seq = main.ConvertNullInt(ddlSuspenseInputTaxAccountSeq.SelectedValue);
            info.close_income_account_seq = main.ConvertNullInt(ddlCloseIncomeAccountSeq.SelectedValue);
            info.close_outcome_account_seq = main.ConvertNullInt(ddlCloseOutcomeAccountSeq.SelectedValue);
            info.close_capital_account_seq = main.ConvertNullInt(ddlCloseCapitalAccountSeq.SelectedValue);
            info.close_income_outcome_account_seq = main.ConvertNullInt(ddlCloseIncomeOutcomeAccountSeq.SelectedValue);
            info.cross_budget_expense_account_seq = main.ConvertNullInt(ddlCrossBudgetExpenseSeq.SelectedValue);
            info.cross_budget_income_account_seq = main.ConvertNullInt(ddlCrossBudgetIncomeSeq.SelectedValue);
            info.dispose_account_seq = main.ConvertNullInt(ddlDisposeSeq.SelectedValue);

            baseAcc.UPDATE(info);
            main.MessageAlert(Page, "บันทึกเรียบร้อย");
        }
    }
}